package com.k.demo.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.k.demo.entity.ChangeStyle;
import com.k.demo.entity.Food;
import com.k.demo.mapper.ChangeStyleMapper;
import com.k.demo.service.ChangeStyleService;

@Service
public class ChangeStyleServiceImpl implements ChangeStyleService{
	
	@Autowired
	private ChangeStyleMapper changeStyleMapper;

	//查找所有变动形式
	public List<ChangeStyle> getAll() {
		// TODO Auto-generated method stub
		return changeStyleMapper.getAll();
	}

	//根据id查找变动形式
	public ChangeStyle getById(int point_change_id) {
		
		return changeStyleMapper.getById(point_change_id);
	}

	//根据输入内容查找变动形式
	public List<ChangeStyle> getByContent(String content) {
		// TODO Auto-generated method stub
		return changeStyleMapper.search(content);
	}

	//根据传入的数组进行批量删除
	public boolean deleteByGroup(List<Integer> list) {
		// TODO Auto-generated method stub
		return changeStyleMapper.deleteByGroup(list);
	}

	//添加新的变动形式对象
	public ChangeStyle addChangeStyle(ChangeStyle changeStyle) {
		int count = changeStyleMapper.addChangeStyle(changeStyle);
		
		if(count > 0) {
			
			return changeStyle;
		}
		return null;
	}

	//修改
	public ChangeStyle modifyChangeStyle(ChangeStyle changeStyle) {
		
		int count = changeStyleMapper.modifyChangeStyle(changeStyle);
		
		if(count > 0) {
			
			return changeStyle;
		}
		return null;
	}

	//假删除
	public int falseDelete(int point_change_id) {
		
		int count = changeStyleMapper.falseDeleteById(point_change_id);
		
		return count;
	}

	//分页显示全部
	public PageInfo<ChangeStyle> getAllWithPage(int pageNum, int pageSize) {
		
		PageHelper.startPage(pageNum,pageSize);
		
		return new PageInfo<ChangeStyle>(changeStyleMapper.getAll());
	}

	//分页显示搜索内容的全部
	public PageInfo<ChangeStyle> getByContentWithPage(int pageNum, int pageSize, String content) {
		
		PageHelper.startPage(pageNum,pageSize);
		
		return new PageInfo<ChangeStyle>(changeStyleMapper.search(content));
	}

}
